<script>
	import checkForUpdates from './common/checkForUpdates.js'
	export default {
		onLaunch: function() {
			// #ifdef APP-PLUS
				let type = 1 
				let newV = '14.0.0'   // 升级版本v
				let oldV = plus.runtime.version  // 新版本
				console.log(newV)
				let checkVersion = checkForUpdates.checkVersion(oldV,newV)  // 校验版本号
				if(type == 1){
					if(checkVersion){
						uni.showModal({
							title: '提示',
							content: '这是一个模态弹窗',
							success: function(res) {
								if (res.confirm) {
									uni.downloadFile({
										url: 'http://zwd.juhuiwangluo.com/sjb.wgt',
										success: (downloadResult) => {
											console.log(downloadResult)
											if (downloadResult.statusCode === 200) {
												plus.runtime.install(downloadResult.tempFilePath, {
													force: true // 为true 不检查版本进行更新
												}, function() {
													plus.runtime.restart();
												}, function(e) {
													console.log(e)
												});
											}
										}
									});
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						});
					}
				}else if(type == 2){
					if(checkVersion){
						let data = JSON.stringify({})
						uni.navigateTo({
							url:'pages/index/index'
						})
					}
				}
				console.log(checkVersion)
				
			// #endif
			
		},
		onShow: function() {
			console.log('App Show')

		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
